// Include files.
#include "ArcadeDriveFilter.hpp"

/**
 *  Apply the filter to an input.
 */
TankValue ArcadeDriveFilter::Apply(const JoystickValue &input) const
{
	/* The following code in this block is derived from 
	 * WPILib, which is licenced under the licence specified
	 * in "Licence-WPILib.txt".
	 */
	
	float y = -input.GetY();
	float rotation = input.GetX();
	
	double left = (y + rotation);
	double right = (y - rotation);
	
	/*
	float moveValue = joystick.GetY();
	float rotateValue = joystick.GetX();
	float left = 0;
	float right = 0;
	
	if (moveValue > 0.0)
	{
		if (rotateValue > 0.0)
		{
			left = moveValue - rotateValue;
			right = max(moveValue, rotateValue);
		}
		else
		{
			left = max(moveValue, -rotateValue);
			right = moveValue + rotateValue;
		}
	}
	else
	{
		if (rotateValue > 0.0)
		{
			left = - max(-moveValue, rotateValue);
			right = moveValue + rotateValue;
		}
		else
		{
			left = moveValue - rotateValue;
			right = - max(-moveValue, -rotateValue);
		}
	}
	*/
	
	return TankValue(left, right);
}
